<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
  </head>
  <body>
    <script>
      var year = prompt("请输入年份");
      // 输入月份不对的输入将一直输入
      while (true) {
        var month = prompt("请输入月份");
        if (month >= 1 && month <= 12) {
          break;
        } else {
          alert("您输入的不对奥，请重新输入");
        }
      }
      //   输入每个月的日期，不能超过他的最大值
      while (true) {
        var day = prompt("请输入您日期");
        var maxday = 0;
        if (
          month == 2 &&
          ((year % 4 == 0 && year % 100 != 0) || year % 400 == 0)
        ) {
          maxday = 29;
          if (day > maxday) {
            alert("这个月没有这么多天奥");
            continue;
          }
          break;
        } else if (month == 2) {
          maxday = 28;
          if (day > maxday) {
            alert("这个月没有这么多天奥");
            continue;
          }
          break;
        } else if (
          month == 1 ||
          month == 3 ||
          month == 5 ||
          month == 7 ||
          month == 8 ||
          month == 10 ||
          month == 12
        ) {
          maxday = 31;
          if (day > maxday) {
            alert("这个月没有这么多天奥");
            continue;
          }
          break;
        } else {
          maxday = 30;
          if (day > maxday) {
            alert("这个月没有这么多天奥");
            continue;
          }
          break;
        }
      }
      alert(`${year}年${month}月${day}日`);
    </script>
  </body>
</html>
